package com.zxw.api.login.producer;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zxw
 * @date 2021-03-28 16:20
 */
@Configuration
public class LoginProducerConfiguration {
    @Value("${rocketmq.namesrc.address}")
    private String namesrcAddress;
    @Value("rocketmq.login.producer.group")
    private String loginProducerGroup;

    @Bean
    public DefaultMQProducer loginMqProducer() throws MQClientException{
        DefaultMQProducer producer = new DefaultMQProducer(loginProducerGroup);
        producer.setNamesrvAddr(namesrcAddress);
        producer.start();
        return producer;
    }
}
